<template>
	<view class="page">
		<view class="login_box">
			<view class="login_title">登录</view>
			<view class="login_box_item">
				<image src="../../static/d_avatar.png" class="u_icon"></image>
				<u--input placeholder="请输入账号" border="none" v-model="name"></u--input>
			</view>
			<view class="login_box_item">
				<image src="../../static/d_pwd.png" class="u_icon"></image>
				<u--input placeholder="请输入密码" type="password" border="none" v-model="pwd"></u--input>
			</view>
			<view class="btn" @click="login">登录</view>
		</view>
	</view>
</template>

<script>
	import {
		api,
		apiBaseUrl,
		http
	} from '@/config/common.js'
	export default {
		data() {
			return {
				name: '',
				pwd: ''
			}
		},
		components: {},
		filters: {},
		mounted() {},
		onLoad(e) {},
		onShow() {},
		onPageScroll(e) {},
		beforeDestroy() {},
		methods: {
			login() {
				uni.showLoading({})
				api.post('api/shop/engineer_login', {phone:this.name,password:this.pwd}).then(res => {
					uni.hideLoading()
					let rst = res.data
					uni.$u.toast(rst.msg)
					if (rst.code == 1) {
						let result = rst.data
						uni.setStorageSync('token', result.token)
						uni.setStorageSync('userInfo', result.userArr)
						 uni.navigateTo({
						 	url:'/pages/kcsj/index'
						 }) 
					}
					// banner
				}).catch(err => {
					uni.hideLoading()
				})
			}
		}
	};
</script>

<style scoped>
	.login_title {
		font-size: 28rpx;
		color: rgb(40, 49, 66);
		text-align: center;
		padding: 40rpx;
	}

	.login_box {
		width: 670rpx;
		margin: 0 auto;
		background: #fff;
		border-radius: 10rpx;
		padding-bottom: 50rpx;
	}

	.btn {
		width: 500rpx;
		height: 80rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		margin: 0 auto;
		margin-top: 100rpx;
		background-color: rgb(28, 134, 153);
		color: #fff;
		border-radius: 40rpx;
		font-size: 32rpx;
	}

	.login_box_item {
		width: 620rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		border-bottom: 1px solid #eeeeee;
		margin-bottom: 40rpx !important;
		margin: 0 auto;
		height: 80rpx;
	}

	.u_icon {
		width: 40rpx;
		height: 40rpx;
		margin-right: 10rpx;
	}

	page {
		display: flex;
		justify-content: center;
		/* 水平居中 */
		align-items: center;
		/* 垂直居中 */
		height: 100vh;
		/* 使div的高度为视口高度 */
		background-color: rgb(28, 134, 153);
	}
</style>